﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Castle.ActiveRecord;
using NHibernate.Criterion;
using LIB;
using System.Collections;
using System.Web.UI.HtmlControls;


public partial class chi_tiet_nha : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        using (new SessionScope())
        {
            int id = ConvertUtility.ToInt32(Request.QueryString["id"]);
            if (id > 0)
            {
                Home_Info homeInfo = Home_Info.Find(id);
                lblHomeName.Text = homeInfo.homeName;
                lblHomeGia.Text = ConvertUtility.DocTienBangChu(homeInfo.homeGia*1000," VNĐ");
                litThongTinChung.Text ="<div class='bound'>"+ homeInfo.homeComonInfo+"</div>";
                litDemoVideo.Text = homeInfo.homeDemoVideo;

                imgDemoMap.ImageUrl = App_Constant.PATH_UP_IMAGES_MAP + "/" + homeInfo.homeDemoBanDo;
                Conjunction conj = new Conjunction();
                conj.Add(Expression.Eq("imageType", 1));
                conj.Add(Expression.Eq("imageObjectID", homeInfo.id));

                Image_Info[] lstImages = Image_Info.FindAll(conj);
                litLstImg.Text = "";
                if (lstImages.Length > 0)
                {
                    for (int i = 0; i < lstImages.Length; i++)
                        litLstImg.Text += "<img src='" + App_Constant.PATH_UP_CONTENT + "/" + lstImages[i].imageUrl + "' />";
                }
                               
                if (homeInfo.homeIsShowPrivate)
                    litThongTinRieng.Text = "<div class='bound'>" + homeInfo.homePrivateInfo + "</div>";
                Page.Title = homeInfo.homeName;
                seo(homeInfo);
            }
        }

    }

    protected void seo(Home_Info homeInfo)
    {
        string title = "";
        string keyword = "";
        string description = "";
        Home_Cat_Info[] lstHomeCat = Home_Cat_Info.FindAll(Expression.Eq("homeID", homeInfo.id));
        if (lstHomeCat.Length > 0)
        {
            for (int i = 0; i < lstHomeCat.Length; i++)
            {
                Category_Info catInfo = Category_Info.Find(lstHomeCat[i].catID);
                if (catInfo != null)
                {
                    title += catInfo.catMetaTitle + " - ";
                    keyword += catInfo.catMetaKey + " - ";
                    description += catInfo.catMetaDes + " - ";
                }
            }
        }
        Page.Title =homeInfo.homeName+" - " + title;
        //keywords
        HtmlMeta keywords = new HtmlMeta();
        keywords.Name = "keywords";
        keywords.Content =keyword;
        Page.Header.Controls.Add(keywords);
        //description
        HtmlMeta descriptions = new HtmlMeta();
        descriptions.Name = "description";
        descriptions.Content = description;
        Page.Header.Controls.Add(descriptions);
    }
}